/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.kj.member.service;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.kj.member.dao.MemberDao;
import com.jeesite.modules.kj.member.entity.Member;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 员工管理Service
 * @author ThinkGem
 * @version 2017-03-25
 */

@Service
@Transactional(readOnly=true)
public class MemberService extends CrudService<MemberDao, Member> {

	/**
	 * 获取单条数据
	 */
	@Override
	public Member get(Member member) {
		return super.get(member);
	}

	/**
	 * 查询分页数据
	 */
	@Override
	public Page<Member> findPage(Member member) {
		return super.findPage(member);
	}

	/**
	 * 保存数据（插入或更新）
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(Member member) {
		if (member.getIsNewRecord()){
			if (dao.get(member) != null){
				throw newValidationException("会员编码已存在");
			}
		}
		super.save(member);
	}

	/**
	 * 删除数据
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(Member member) {
		super.delete(member);
	}
//
//	/**
//	 * 查询当前员工关联的附属机构信息
//	 */
//	public List<EmployeeOffice> findEmployeeOfficeList(Employee employee){
//		EmployeeOffice employeeOffice = new EmployeeOffice();
//		employeeOffice.setEmpCode(employee.getEmpCode());
//		return employeeOfficeDao.findList(employeeOffice);
//	}
}